Skip to content

Colour-coded nodes by year#11

Open
harise01 wants to merge 1 commit into
mainfrom
colournodes
Open

Colour-coded nodes by year#11
harise01 wants to merge 1 commit into
mainfrom
colournodes

Conversation

@harise01
Copy link
Copy Markdown

@harise01 harise01 commented Jun 5, 2026

Completed and tested implementation of colour-coding nodes by year

const { selectedCourse, highlightedSet } = useExplorerStore();
const dimmed = selectedCourse !== null && !highlightedSet.has(data.code);

const year = data.code.charAt(5);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR looks good overall! One small robustness suggestion: right now this assumes that the "year" of the course will always be at index 5, which is true for subjects with 4 letter subject codes (e.g. COMP 1405).

However, if we expand to more subjects related to COMP, there are some 3 letter subject codes (e.g. BIT, IMD, NET etc.).

To always get the first digit in the course code, regardless of how long the subject code is, using regex would be better here. Something like:
data.code.match(/\d/)?.[0];

(Not 100% sure that's the right regex so I'd check it with some examples to confirm)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants